﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Data.Linq;

namespace Srs.Sample.Services
{
    [DataContract]
    public class Dealer
    {
        private int _id;
        private int _customerID;
        private string _name;
        private string _phoneNumber;

        #region Properties

        [DataMember]
        public int ID
        {
            get { return _id; }
            set { _id = value; }
        }

        [DataMember]
        public int CustomerID
        {
            get { return _customerID; }
            set { _customerID = value; }
        }

        [DataMember]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        [DataMember]
        public string PhoneNumber
        {
            get { return _phoneNumber; }
            set { _phoneNumber = value; }
        }

        #endregion

        public Dealer (int id, string name)
        {
            _id = id;
            _name = name;
        }

        internal Dealer (Sample_Dealer sd)
        {
            _id = sd.ID;
            _name = sd.Name;
            _customerID = sd.CustomerID;
            _phoneNumber = sd.PhoneNumber;
        }

        internal static List<Dealer> Convert (IQueryable<Sample_Dealer> query)
        {
            List<Dealer> returnList = new List<Dealer>();

            foreach (var entity in query)
                returnList.Add(new Dealer(entity));

            return returnList;
        }
    }
}
